﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:FunctionScope.Views"
             xmlns:Models="clr-namespace:FunctionScope.Models" 
             xmlns:Convertors="clr-namespace:FunctionScope.Views.Converters"
             x:Class="FunctionScope.Views.SinFunctionView"
             mc:Ignorable="d" 
             d:DesignHeight="129.836" 
             d:DesignWidth="159.344">
    
    <UserControl.DataContext>
        <Models:SinFunctionModel/>
    </UserControl.DataContext>

    <UserControl.Resources>
        <Convertors:FrequencyConverter x:Key="FrequencyConvertor"/>
        <Convertors:PhaseConverter x:Key="PhaseConvertor"/>
        <Convertors:AmplitudeConvertor x:Key="AmplitudeConvertor"/>
    </UserControl.Resources>
    
    <Grid>
        <Grid.Background>
            <SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlLightColorKey}}"/>
        </Grid.Background>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid Margin="5,0,0,0"/>
        <Label x:Name="lbl_Freq" Content="Frequency" Margin="0,0,0,0" Grid.Row="1" HorizontalAlignment="Right" />
        <Label x:Name="lbl_Phase" Content="Phase" Margin="0,0,0,0" Grid.Row="2" HorizontalAlignment="Right"/>
        <Label x:Name="lbl_Amplitude" Content="Amplitude" Margin="0,0,0,0" Grid.Row="3" HorizontalAlignment="Right"/>
        <Label x:Name="lbl_DCOffset" Content="DCOffset" Margin="0,0,0,0" Grid.Row="4" HorizontalAlignment="Right"/>
        
        <!-- Input sliders -->
        <Slider x:Name="sld_Freq" Grid.Column="1" Margin="0,0,0,0" Grid.Row="1" Value="{Binding Frequency, Mode=TwoWay}" Minimum="0.1" Maximum="50" IsSnapToTickEnabled="True" TickFrequency="0.1"/>
        <Slider x:Name="sld_Phase" Grid.Column="1" Margin="0,0,0,0" Grid.Row="2" Value="{Binding Phase, Mode=TwoWay}" Minimum="0.0" Maximum="360" IsSnapToTickEnabled="True" TickFrequency="1"/>
        <Slider x:Name="sld_Amplitude" Grid.Column="1" Margin="0,0,0,0" Grid.Row="3" Value="{Binding Amplitude, Mode=TwoWay}" Minimum="0.1" Maximum="2" IsSnapToTickEnabled="True" TickFrequency="0.1"/>
        <Slider x:Name="sld_DcOffset" Grid.Column="1" Margin="0,0,0,0" Grid.Row="4" Value="{Binding DcOffset, Mode=TwoWay}" Minimum="-1" Maximum="1" IsSnapToTickEnabled="True" TickFrequency="0.1"/>

        <!--Header label-->
        <Label x:Name="lbl_Label" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Content="{Binding Name, Mode=OneWay}"/>
        
        <!--Value labels-->
        <Label x:Name="lbl_FreqVal" Grid.Column="2" HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Row="1" Content="{Binding Frequency, Mode=OneWay, Converter={StaticResource FrequencyConvertor}}"/>
        <Label x:Name="lbl_PhaseVal" Grid.Column="2" HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Row="2" Content="{Binding Phase, Mode=OneWay, Converter={StaticResource PhaseConvertor}}"/>
        <Label x:Name="lbl_AmplitudeVal" Grid.Column="2" HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Row="3" Content="{Binding Amplitude, Mode=OneWay, Converter={StaticResource AmplitudeConvertor}}"/>
        <Label x:Name="lbl_DCOffsetVal" Grid.Column="2" HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Row="4"  Content="{Binding DcOffset, Mode=OneWay, Converter={StaticResource AmplitudeConvertor}}"/>
    </Grid>
</UserControl>
